# 导入模块
import os
from openpyxl import load_workbook  # 确保已导入工作簿加载模块

# 设置文件夹路径
path = './各部门利润表汇总/'

# 返回当前目录下所有文件名
files = os.listdir(path)

# 循环文件名列表
for file in files:
    # 拼接文件路径
    file_path = os.path.join(path, file)  # 使用 os.path.join 更加安全

    # 打开工作簿
    wb = load_workbook(file_path)

    # 打开工作表
    ws = wb.active

# 打开工作簿
wb = load_workbook(file_path)

# 打开工作表
sheet = wb.active

# 调整列宽
sheet.column_dimensions['A'].width = 10
sheet.column_dimensions['B'].width = 25
sheet.column_dimensions['C'].width = 50
sheet.column_dimensions['D'].width = 10
sheet.column_dimensions['E'].width = 20
sheet.column_dimensions['F'].width = 15